<template>
	<view>
		<uni-nav-bar left-icon="back" @clickLeft="goback" fixed title="用户评价" status-bar="true"></uni-nav-bar>
		<view class="plist">
			<view class="ite">
				<view class="items_user">
					<view class="user_flex">
						<image class="uimg" :src="Info.userHead?Info.userHead:'/static/toux.png'" mode="aspectFit"></image>
						<view class="uname">
							{{Info.userName}}
						</view>
					</view>
					<view class="time">{{Info.createTime}}</view>
				</view>
				<view class="star">
					<uni-rate readonly="true" :value="Info.rating" size='19' activeColor="#000"></uni-rate>
				</view>
				<view class="text">
					{{Info.content}}
				</view>
				<view v-if="Info.img"  class="pimglist" >
					<image v-for="(img,ind) in Info.img" :key="ind" 
					@click.stop="$previewImage(Info.img,ind)"
					:src="img" mode="scaleToFill"></image>
				</view>
				<view class="shop">
					{{Info.productName}}({{Info.productCount}}份)
					<span>￥{{Info.productPrice}}</span><span class="s2">￥{{Info.productPriceOld}}</span>
				</view>
				<view class="imgflex">
					<view class="tipflexs">
						<view class="ites" v-for="(tag,ind) in Info.tag" :key="ind">
							{{tag}}
						</view>
					</view>
					<view class="img_r">
						<view class="r">
							<span>{{Info.replyCount}}</span>
							<uni-icons size="20" color='#D9D9D9' type="chat"></uni-icons>
						</view>
						<view class="r" @click.stop="handleDZ()">
							<span>{{Info.likeCount}}</span>
							<uni-icons v-if="Info.likeFlag" size="20" color='#000000' type="hand-up-filled"></uni-icons>
							<uni-icons v-else size="20" color='#D9D9D9' type="hand-up"></uni-icons>
						</view>
					</view>
				</view>
				<view class="dialog" v-if="uulist.length!=0">
					<view class="itemss" @click="pagePer(item)" v-for="(item,index) in uulist" :key="index">
						<view class="items_users">
							<view class="items_conts">
								<view class="user_flexs">
									<image class="uimg" :src="item.sendUserHead?item.sendUserHead:'/static/toux.png'" mode=""></image>
									<view class="uname">{{item.sendUserName}}</view>
									<view class="tipss" v-if="item.sendUserShop == 1">
										店铺
									</view>
									<view class="tipss1" v-if="item.sendUserShop == 2">
										平台
									</view>
								</view>
								<view class="cont" v-if="item.reply==1">
									<view class="hf">
										回复
									</view>
									<span>{{item.receiveUserName}}</span>
								</view>
							</view>
							<view class="time">{{item.createTime}}</view>
						</view>
						<view class="contxt">
							{{item.content}}
						</view>
					</view>
				</view>
			</view>
			<view class="" style="height: 150rpx;">
				
			</view>
		</view>
		<view class="inputfooter" :style="{bottom:inputheight + 'px'}">
			<view class="vwe">
				<textarea confirm-type="send" :adjust-position="false" type="text" placeholder-class="textss"
					:placeholder="'回复:'+title" v-model="params.content" @keyboardheightchange='keyboardheightchange'
					auto-height :maxlength='-1' @confirm="fs" />
				<view class="btn" @click="fs">
					提交
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		commentInfo,
		commentReplyList,
		commentReplyadd,
		commentLike
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				inputheight: 0,
				Info: {},
				// params:{
				// 	commentId:0
				// },
				params: {
					commentId: '', //评论ID
					content: '', //回复内容
					replyId: '', //回复ID
					receiveUserType: '', //接收人类型
					receiveUserId: '', //接收人的ID
					pageNum: 1,
					pageSize: 10
				},
				title: '',
				uulist: []

			};
		},
		onLoad(option) {
			this.params.commentId = option.id
			this.getinfo()
			this.getlist()
		},
		onReachBottom() {
			this.params.pageNum++
			this.getlist()
		},
		methods: {
			getinfo(){
				commentInfo({
					id:this.params.commentId
				}).then(res => {
					if (res.data.img != '' && res.data.img !=null) {
						res.data.img = res.data.img.split(',')
					}
					if (res.data.tag != '' && res.data.tag !=null) {
						res.data.tag = res.data.tag.split(',')
					}
					this.Info = res.data
					this.title = res.data.userName
				})
			},
			handleDZ(){
				this.Info.likeFlag = !this.Info.likeFlag
				commentLike({id:this.params.commentId}).then(res=>{
					this.getinfo()
				})
			},
			getlist() {
				commentReplyList(this.params).then(res => {
					this.uulist.push(...res.rows)
				})
			},
			fs() {
				commentReplyadd(this.params).then(res => {
					if (res.code == 200) {
						this.uulist = []
						this.params.pageNum = 1
						this.getlist()
						this.params.content = ''
					}
				})
			},
			pagePer(item) {
				console.log(item);
				this.title = item.sendUserName
				this.params.replyId = item.id
				this.params.receiveUserType = item.sendUserShop
				this.params.receiveUserId = item.sendUserId
				// uni.navigateTo({
				// 	url: '/mainpage/perComment'
				// })
			},
			preview(list) {
				uni.previewImage({
					urls: list,
				});
			},
			goback() {
				uni.navigateBack()
			},

			keyboardheightchange(e) {
				if (e.detail.height == 0) {
					this.inputheight = 0
				} else {
					this.inputheight = e.detail.height - uni.getStorageSync('safeAreaInsets').bottom
				}
			},

		}
	}
</script>

<style lang="scss">
	.inputfooter {
		width: 750rpx;
		position: fixed;
		bottom: 0%;
		background: #FFFFFF;
		box-shadow: 0rpx -4rpx 7rpx 0rpx rgba(210, 185, 178, 0.38);
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.vwe {
			width: 750rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx;
			box-sizing: border-box;

			.textss {
				color: #979797;
			}

			textarea {
				width: 532rpx;
				background: #FAF9F7;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				align-items: center;
				box-sizing: border-box;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #000;
				padding: 10rpx 15rpx;
				box-sizing: border-box;
			}

			.btn {
				width: 160rpx;
				height: 80rpx;
				background: #000000;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 80rpx;
				text-align: center;
			}
		}

	}

	.plist {
		font-family: PingFang SC, PingFang SC;
		padding: 0rpx 20rpx 40rpx 20rpx;
		box-sizing: border-box;
		.ite {
			border-top: 1px solid #eee;
			padding: 30rpx 0rpx;
			.items_user {
				display: flex;
				align-items: center;
				justify-content: space-between;
				.user_flex {
					display: flex;
					align-items: center;
					.uimg {
						width: 50rpx;
						height: 50rpx;
						border-radius: 25rpx;
					}
					.uname {
						font-weight: bold;
						font-size: 32rpx;
						color: #000000;
						margin-left: 10rpx;
					}
				}
				.time {
					font-size: 24rpx;
					color: #979797;
				}
			}
			.star {
				margin: 14rpx auto;
			}
			.text {
				font-weight: 500;
				font-size: 28rpx;
				color: #000000;
				word-break: break-all;
				margin-bottom: 20rpx;
			}

			.pimglist {
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;
				image {
					width: 230rpx;
					height: 210rpx;
					border-radius: 10rpx;
				}
			}

			.shop {
				height: 68rpx;
				background: #F3F3F3;
				border-radius: 0rpx 0rpx 0rpx 0rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #000000;
				padding: 0rpx 20rpx;
				line-height: 68rpx;
				box-sizing: border-box;
				display: inline-block;
				span {
					font-family: 'FINE';
					font-weight: bold;
				}

				.s2 {
					color: #D1CDCD;
					font-size: 22rpx;
					text-decoration-line: line-through;
					margin-left: 6rpx;
				}
			}

			.imgflex {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin: 20rpx auto;

				.tipflexs {
					flex: 1;
					display: flex;

					.ites {
						height: 48rpx;
						background: #036029;
						border-radius: 0rpx 0rpx 0rpx 0rpx;
						padding: 0rpx 14rpx;
						text-align: center;
						line-height: 48rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #FFFFFF;
						margin-right: 10rpx;
					}
				}

				.img_r {
					display: flex;
					align-items: center;

					.r {
						display: flex;
						margin-left: 20rpx;
						align-items: center;
					}

					span {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #D1CDCD;
					}
				}
			}

			.dialog {
				background: #FAF9F7;
				padding: 22rpx 24rpx;
				border-radius: 6rpx;
				.itemss {
					margin-bottom: 24rpx;

					.items_users {
						display: flex;
						align-items: center;
						justify-content: space-between;

						.items_conts {
							display: flex;
							align-items: center;

							.cont {
								display: flex;
								align-items: center;
								font-family: PingFang SC, PingFang SC;
								font-weight: 500;
								font-size: 28rpx;
								color: #000000;

								.hf {
									color: #CE7034;
									margin: 0 10rpx;
								}
							}
						}

						.user_flexs {
							display: flex;
							align-items: center;
							.uimg {
								width: 40rpx;
								height: 40rpx;
								border-radius: 20rpx;
							}
							.uname {
								font-size: 28rpx;
								color: #000000;
								margin-left: 10rpx;
							}
							.tipss{
								width: 80rpx;
								background: #000000;
								border-radius: 0rpx 0rpx 0rpx 0rpx;
								font-family: PingFang SC, PingFang SC;
								font-weight: 500;
								font-size: 24rpx;
								color: #FFFFFF;
								line-height: 36rpx;
								text-align: center;
								margin-left: 10rpx;
							}
							.tipss1{
								width: 80rpx;
								background: #036029;
								border-radius: 0rpx 0rpx 0rpx 0rpx;
								font-family: PingFang SC, PingFang SC;
								font-weight: 500;
								font-size: 24rpx;
								line-height: 36rpx;
								color: #FFFFFF;
								text-align: center;
								margin-left: 10rpx;
							}
						}

						.time {
							font-size: 24rpx;
							color: #979797;
						}
					}

					.contxt {
						margin-top: 20rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
					}
				}

				.items:last-child {
					margin-bottom: 0rpx;
				}

			}
		}
	}
</style>